﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LL.Common;
using NanoERP.Model.Poco;
using NanoERP.Business.Permission;

namespace NanoERP.Infrastructure
{
    public class AuthHelper
    {
        public static bool Login(string userName, string password)
        {
            SYS_User user = new UserService()
                .GetUser(userName, password);
            if (user != null)
                LogonSession.Set(user);
            return user != null;
        }

        public static IList<string> GetRights(LogonUser logonUser, ICollection<string> moduleNames)
        {
            string names = moduleNames.ToArray().Warp("'").Combine(',');
            return new ModuleRightService().GetModulesRights(logonUser.Id, names);
        }
    }
}
